const routes = [
  {
    path: '/',
    name: 'layout',
    component: () => import('../views/layout/index.vue'),
    meta: {
      title: '主页'
    },
    redirect: {
      name: 'usere'
    },
    children: [
      {
        path: '/',
        name: 'userman',
        component: () => import('../views/userman/index.vue'),
        meta: {
          title: '用户管理'
        },
        redirect: {
          name: 'usere'
        },
        children: [
          {
            path: 'usere',
            name: 'usere',
            meta: {
              title: '企业用户'
            },
            component: () => import('../views/users-e/index.vue')
          },
          {
            path: 'users',
            name: 'users',
            meta: {
              title: '个人用户'
            },
            component: () => import('../views/users-u/index.vue')
          }
        ]
      },
      {
        path: '/testmanage',
        name: 'testmanage',
        meta: { title: '测评管理' },
        component: () => import('../views/evaluation/index.vue')
      },

      {
        path: '/userinfo',
        name: 'userinfo',
        meta: { title: '用户信息' },
        component: () => import('../views/user/userinfo.vue')
      },
      {
        path: '/manage',
        name: 'manage',
        meta: { title: '项目管理' },
        component: () => import('../views/manage/index.vue'),

        redirect: {
          name: 'usere'
        },
        children: [
          {
            path: 'projectmg',
            name: 'projectmg',
            meta: {
              title: '项目列表'
            },
            component: () => import('../views/projectmg/manage.vue')
          },
          {
            path: 'Candidate',
            name: 'Candidate',
            meta: {
              title: '候选人管理'
            },
            component: () => import('../views/Candidate/index.vue')
          },
          {
            path: 'details/:id',
            name: 'details',
            meta: { title: '项目详情' },
            component: () => import('../views/projectmg/projectDetails.vue')
          },
          {
            path: 'addItem',
            name: 'addItem',
            meta: { title: '新增' },
            component: () => import('../views/projectmg/index.vue')
          }
        ]
      },
      {
        path: '/index',
        name: 'index',
        meta: { title: ' 主页' },
        component: () => import('../views/index/index.vue')
      }
    ]
  },
  {
    path: '/pdf',
    name: 'pdf',
    meta: { title: 'pdf' },
    component: () => import('../views/pdf/pdf.vue')
  },
  {
    path: '/zhigen',
    name: 'zhigen',
    meta: { title: 'zhigen' },
    component: () => import('../views/zhigen/zhigen.vue')
  },
  {
    path: '/findPass',
    name: 'findPass',
    meta: { title: '找回密码' },
    component: () => import('../views/login/findPass.vue')
  },
  {
    path: '/login',
    name: 'login',
    meta: { title: '登录' },
    component: () => import('../views/login/index.vue')
  },
  {
    path: '/dati',
    name: 'dati',
    meta: { title: '答题' },
    component: () => import('../views/dati/index.vue'),
    children: [
      {
        path: 'welcome/:id',
        name: 'welcome',
        meta: {
          title: '欢迎答题页'
        },
        component: () => import('../views/dati/welcome.vue')
      },
      {
        path: 'dataEdit2',
        name: 'dataEdit2',
        meta: {
          title: '欢迎答题页'
        },
        component: () => import('../views/dati/dataEdit2.vue')
      },
      {
        path: 'dataEdit',
        name: 'dataEdit',
        meta: {
          title: '应答者资料'
        },
        component: () => import('../views/dati/dataEdit.vue')
      },
      {
        path: 'wenjuan',
        name: 'wenjuan',
        meta: {
          title: '问卷'
        },
        component: () => import('../views/dati/wenjuan.vue')
      },
      {
        path: 'findPass',
        name: 'findPass',
        meta: {
          title: '找回密码'
        },
        component: () => import('../views/login/findPass.vue')
      }
    ]
  },

  {
    path: '*',
    redirect: {
      name: 'index'
    }
  }
]

function recursionRouter(userRouter = [], allRouter = []) {
  var realRoutes = []
  var permission = [
    {
      name: '首页',
      code: '001'
    },
    {
      name: '超级管理员',
      code: '003'
    },
    {
      name: '企业用户',
      code: '004'
    },
    {
      name: '评测管理',
      code: '005'
    },
    {
      name: '测评预览',
      code: '006'
    },
    {
      name: '消息管理',
      code: '007'
    }
  ]
  switch (item.code) {
    case '001':
      arr.push({
        path: '/index',
        name: 'index',
        meta: { title: ' 主页' },
        component: () => import('../views/index/index.vue')
      })
      break
    case '002':
      if (item == '002') {
      }
      break
  }
  // 前端
  allRouter.forEach((v, i) => {
    userRouter.forEach((item, index) => {
      if (item.name === v.meta.name) {
        if (item.children && item.children.length > 0) {
          v.children = recursionRouter(item.children, v.children)
        }
        realRoutes.push(v)
      }
    })
  })
  return realRoutes
}
export default routes
